package jsave.action;

import java.io.File;

import jsave.exception.JSaveArretSauvegarde;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;

public class ActionIgnorer extends Action {
	
	private static final Logger log = Logger.getLogger(ActionIgnorer.class);

	
	public ActionIgnorer(int typeAction) {
		
		if (typeAction == Action.ACTION_A || typeAction == Action.ACTION_B || typeAction == Action.ACTION_C || typeAction == Action.ACTION_D) {
			this.typeAction = typeAction;
		} else {
			log.log(Level.ERROR, "ERREUR - Le type d'action '"+typeAction+"' ne correspond pas a l'action 'ActionIgnorer' ");
		}
	}
	
	
	public void executer(File s, File d) throws JSaveArretSauvegarde {
		
		if (typeAction == ACTION_A || typeAction == ACTION_C) { 
			log.log(Level.INFO, "IG - "+s.getPath());
			if (s.isDirectory()) {
				nbDossiersIgnores++;
			} else {
				nbFichiersIgnores++;
			}
		} else {
			log.log(Level.INFO, "IG - "+d.getPath());
			if (d.isDirectory()) {
				nbDossiersIgnores++;
			} else {
				nbFichiersIgnores++;
			}
		}
	}
	
	public String getNom() {
		return "IGNORER";
	}
}
